﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using animexx.ViewModels;
using animexx.Models;

namespace animexx
{
    public partial class ENSFolderView : PhoneApplicationPage
    {
        ENSFolderViewModel data;

        public ENSFolderView()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            data = new ENSFolderViewModel();

            string id = "";
            string typ = "";

            if (NavigationContext.QueryString.TryGetValue("ordner_id", out id) &&
                NavigationContext.QueryString.TryGetValue("ordner_typ", out typ))
            {
                data.LoadData(id,typ);
            }
            else
            {
                data.LoadData();
            }

            DataContext = data;
        }

        private void ENSFolderAllList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("SelectionChanged");
        }

        private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            ENS ens = ((FrameworkElement)sender).DataContext as ENS;
            if (ens!=null)
                NavigationService.Navigate(new Uri("/ENSView.xaml?ens_id=" + ens.id, UriKind.Relative));
        }
    }
}